import React from 'react'
import PropTypes from 'prop-types'
import {Table} from 'antd'
import AnimTableBody from 'components/DataTable/AnimTableBody'
import '../../../utils/index'

const {Column, ColumnGroup} = Table

const List = ({isMotion, ...tableProps}) => {

  const AnimateBody = (props) => {
    return <AnimTableBody {...props} />
  }

  const CommonBody = (props) => {
    return <tbody {...props} />
  }

  const toDefault = (val) => val ? val : 0

  const toRate = (val) => toDefault(val) + '%'

  const toYuan = (val) => toDefault(val) + '元'

  return (
    <Table
      {...tableProps}
      scroll={{x: 4000}}
      simple
      rowKey={record => record.id}
      components={{
        body: {wrapper: isMotion ? AnimateBody : CommonBody},
      }}
    >
      <Column title={'组别'} dataIndex={'groupName'} key={'groupName'}/>
      <Column title={'员工姓名'} dataIndex={'empName'} key={'empName'}/>
      <Column title={'进线量'} dataIndex={'newLineNum'} key={'newLineNum'} render={toDefault}/>
      <Column title={'沟通量'} dataIndex={'communicateNum'} key={'communicateNum'} render={toDefault}/>
      <Column title={'沟通率'} dataIndex={'communicateRate'} key={'communicateRate'} render={toRate}/>
      <Column title={'删除量'} dataIndex={'deleteNum'} key={'deleteNum'} render={toDefault}/>
      <Column title={'删除率'} dataIndex={'deleteRate'} key={'deleteRate'} render={toRate}/>
      <ColumnGroup title={'热线成交'}>
        <Column title={'成交量'} dataIndex={'immediacyDealNum'} key={'immediacyDealNum'} render={toDefault}/>
        <Column title={'成交金额'} dataIndex={'immediacyDealAmount'} key={'immediacyDealAmount'} render={toYuan}/>
        <Column title={'成单均价'} dataIndex={'immediacyDealAvg'} key={'immediacyDealAvg'} render={toYuan}/>
        <Column title={'成交率'} dataIndex={'immediacyDealRate'} key={'immediacyDealRate'} render={toRate}/>
      </ColumnGroup>
      <ColumnGroup title={'后续成交'}>
        <Column title={'成交量'} dataIndex={'afterDealNum'} key={'afterDealNum'} render={toDefault}/>
        <Column title={'成交金额'} dataIndex={'afterDealAmount'} key={'afterDealAmount'} render={toYuan}/>
        <Column title={'成单均价'} dataIndex={'afterDealAvg'} key={'afterDealAvg'} render={toYuan}/>
        <Column title={'成交率'} dataIndex={'afterDealRate'} key={'afterDealRate'} render={toRate}/>
      </ColumnGroup>
      <ColumnGroup title={'热线+后续成交'}>
        <Column title={'成交量'} dataIndex={'preTotalDealNum'} key={'preTotalDealNum'} render={toDefault}/>
        <Column title={'成交金额'} dataIndex={'preTotalDealAmount'} key={'preTotalDealAmount'} render={toYuan}/>
        <Column title={'成单均价'} dataIndex={'preTotalDealAvg'} key={'preTotalDealAvg'} render={toYuan}/>
        <Column title={'成交率'} dataIndex={'preTotalDealRate'} key={'preTotalDealRate'} render={toRate}/>
      </ColumnGroup>
      <Column title={'活动成交量'} dataIndex={'activityDealNum'} key={'activityDealNum'} render={toDefault}/>
      <Column title={'活动成交金额'} dataIndex={'activityDealAmount'} key={'activityDealAmount'} render={toYuan}/>
      <Column title={'活动成单均价'} dataIndex={'activityDealAvg'} key={'activityDealAvg'} render={toYuan}/>
      <ColumnGroup title={'复购成交'}>
        <Column title={'首复成交量'} dataIndex={'firstRebuyNum'} key={'firstRebuyNum'} render={toDefault}/>
        <Column title={'首复成交金额'} dataIndex={'firstRebuyAmount'} key={'firstRebuyAmount'} render={toYuan}/>
        <Column title={'二复成交量'} dataIndex={'secondRebuyNum'} key={'secondRebuyNum'} render={toDefault}/>
        <Column title={'二复成交金额'} dataIndex={'secondRebuyAmount'} key={'secondRebuyAmount'} render={toYuan}/>
        <Column title={'三复成交量'} dataIndex={'thirdRebuyNum'} key={'thirdRebuyNum'} render={toDefault}/>
        <Column title={'三复成交金额'} dataIndex={'thirdRebuyAmount'} key={'thirdRebuyAmount'} render={toYuan}/>
        <Column title={'合计成交量'} dataIndex={'rebuyTotalNum'} key={'rebuyTotalNum'} render={toDefault}/>
        <Column title={'合计成交金额'} dataIndex={'rebuyTotalAmount'} key={'rebuyTotalAmount'} render={toYuan}/>
        <Column title={'合计成交均价'} dataIndex={'rebuyTotalAvg'} key={'rebuyTotalAvg'} render={toYuan}/>
      </ColumnGroup>
      <Column title={'复购活动成交量'} dataIndex={'activityRebuyDealNum'} key={'activityRebuyDealNum'} render={toDefault}/>
      <Column title={'复购活动成交金额'} dataIndex={'activityRebuyDealAmount'} key={'activityRebuyDealAmount'} render={toYuan}/>
      <Column title={'复购活动成交均价'} dataIndex={'activityRebuyDealAvg'} key={'activityRebuyDealAvg'} render={toYuan}/>
      <Column title={'总成交量'} dataIndex={'totalDealNum'} key={'totalDealNum'} render={toDefault}/>
      <Column title={'总成交金额'} dataIndex={'totalDealAmount'} key={'totalDealAmount'} render={toYuan}/>
      <Column title={'已收定金'} dataIndex={'receivedDeposit'} key={'receivedDeposit'} render={toYuan}/>
      <Column title={'进线均线广告费'} dataIndex={'ooo1'} key={'p1'} render={toYuan}/>
      <Column title={'广告费'} dataIndex={'ooo2'} key={'p2'} render={toYuan}/>
      <Column title={'广告业绩比'} dataIndex={'ooo3'} key={'p3'} render={toDefault}/>
      <Column title={'进线均线业绩'} dataIndex={'ooo4'} key={'p4'} render={toYuan}/>
    </Table>
  )
}

List.propTypes = {
  location: PropTypes.object,
}

export default List
